# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# Name:         woniusalestest01
# Description:  
# Author:       Administrator
# Date:         2020/2/10
#-------------------------------------------------------------------------------
# 调用工具类的get_txt方法获取配置文件中的信息
from guitest.woniusales_test01.util.utility import Utility
import time
# driver
class Driven:

	# 生成driver
	def __init__(self,path):

		# 通过类名访问类方法
		contents = Utility.get_json(path)
		from selenium import webdriver
		# 通过反射机制直接获取浏览器驱动对象
		self.driver =getattr(webdriver, contents['BROWSER'])()
		self.driver.implicitly_wait(10)
		self.driver.maximize_window()

	# 打开页面
	def open_page(self,path):
		contents = Utility.get_json(path)
		# http://192.168.1.4:8080/WoniuSales
		URL = 'http://%s:%s/%s' %(contents['HOSTNAME'],contents['PORT'],contents['AURL'])
		self.driver.get(URL)

	# 进行相关功能的测试,体现了对测试的组织
	def do_test(self):
		# 执行登录功能的测试
		from guitest.woniusales_test01.testcase.test_login import LoginTest
		LoginTest().test_login(self.driver,'testdata\\login_data')

if __name__ == '__main__':
	d = Driven('config\\base.conf')
	d.open_page('config\\base.conf')
	d.do_test()